<template>
    <childLayout activeType="articleType" :showSidebar="false" :lunwenName="lunwenName">
        <div class="child-content">
            <div class="item-article-list" v-for="(item, index) in jobList" :key="index">
                <div class="item-article-type">
                    <div class="itme-article-type-show">
                        <div class="item-article-type-icon"> <img src="@/assets/images/article-type-icon.png" alt="">
                        </div>
                        <div class="item-article-type-name">{{ item.majorName }}</div>
                    </div>
                    <div class="item-more" @click="toJumpList(item.majorUid, item.majorName)">更多</div>
                </div>
                <div class="data-table">
                    <el-table :data="item.lunWenList" style="width: 100%;">
                        <el-table-column prop="productNo" label="论文编号" align="center" width="120"/>
                        <el-table-column prop="productName" label="题目" show-overflow-tooltip>
                            <template #default="scope">
                                <span class="product-name" @click="hanldeDetail(scope.row)">{{ scope.row.productName
                                }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="numbers" label="字数" align="center" width="80"/>
                    </el-table>
                </div>

            </div>
        </div>
    </childLayout>
</template>

<script setup>
import childLayout from "@/layout/childLayout";
import { getTitlePaperList } from "@/api/index"
import { onMounted } from "vue";

const router = useRouter();
const route = useRoute()

const jobList = ref([])
const lunwenName = ref('')
const categoryUid = ref('')

const toJumpList = (uid, name) => {
    router.push(`/thesisList?categoryUid=${categoryUid.value}&majorUid=${uid}&name=${lunwenName.value}`)
}

const getArticleList = async () => {
    let res = await getTitlePaperList()
    if (res) {
        jobList.value = res.data
    }
}

const hanldeDetail = (item) => {
    router.push(`/thesisDownload/${item.productUid}`)
}

onMounted(() => {
    categoryUid.value = route.query.categoryUid
    lunwenName.value = route.query.name
	// lunwenUid.value = route.query.id
    getArticleList()
})
</script>

<style lang="scss" scoped>
.child-content {
    display: flex;
    flex-wrap: wrap;

    .item-article-list {
        border-radius: 16px;
        background: rgba(255, 255, 255, 1);
        width: 520px;
        height: auto;
        margin-bottom: 40px;
        padding: 0 5px;

        &:not(:nth-child(2n)) {
            margin-right: 32px;
        }
    }

    .item-article-type {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 48px;
        margin-bottom: 10px;

        .itme-article-type-show {
            display: flex;
            align-items: center;

            .item-article-type-icon {
                width: 20px;
                height: 20px;
                margin-right: 8px;
            }

            .item-article-type-name {
                color: rgba(5, 11, 32, 1);
                font-size: 20px;
                font-weight: 700;
                line-height: 28px;
            }
        }

        .item-more {
            display: flex;
            align-items: center;
            font-size: 14px;
            color: rgba(102, 102, 102, 1);
            cursor: pointer;

            &::after {
                content: "";
                display: block;
                width: 8px;
                height: 8px;
                border: 1px solid rgba(102, 102, 102, 1);
                border-left-color: transparent;
                border-bottom-color: transparent;
                transform: rotate(45deg);
                margin-left: 2px;
            }
        }
    }
}

.product-name {
    color: rgba(51, 133, 255, 1);
    cursor: pointer;
}

.data-table {
    width: 100%;
    height: auto;
    position: relative;
    box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.05);
}

::v-deep {
    .el-table th.el-table__cell {
        background: rgba(244, 247, 255, 1);
        border-bottom-color: transparent;
        color: rgba(5, 11, 32, 1);
    }
}
</style>